using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices.Admin;
using Shop.Model.Dto.Admin.Gift;
using Shop.Model.View.Admin.Gift;

namespace Shop.AdminApi.Controllers;

/// <summary>
/// 赠品服务
/// </summary>
[ApiController]
[Route("admin/[controller]")]
public class GiftController:ShopControllerBase
{
    private readonly IGiftService _giftService;
    private readonly IUserContext _userContext;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="giftService"></param>
    /// <param name="userContext"></param>
    public GiftController(IGiftService giftService, IUserContext userContext)
    {
        _giftService = giftService;
        _userContext = userContext;
    }

    /// <summary>
    /// 赠品活动列表
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("GiftList")]
    public AppResult<PageModel<GiftListVo>> GiftList([FromQuery] GiftListDto dto)
        => _giftService.GiftList(dto);

    /// <summary>
    /// 添加赠品活动
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpPost("AddGift")]
    public AppResult AddGift(AddGiftDto dto)
        => _giftService.AddGift(dto);

    /// <summary>
    /// 赠品活动详情
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("GiftInfo")]
    public AppResult<GiftInfoVo> GiftInfo([FromQuery] long dto)
        => _giftService.GiftInfo(dto);

    /// <summary>
    /// 结束赠品活动
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("GiftDown")]
    public AppResult GiftDown([FromQuery] long dto)
        => _giftService.GiftDown(dto);

    /// <summary>
    /// 编辑赠品活动
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpPost("GiftEdit")]
    public AppResult GiftEdit(GiftEditDto dto)
        => _giftService.GiftEdit(dto);
}